using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SiteManager;

public partial class Doctor_showOptions : System.Web.UI.Page
{
    public string strWhich = "";
    private string strSortby = "";
    public string strPageHeader = "";
    string strHelpHint = "";
    Manager _objDB = new Manager(true,"ConnectionString");
    protected int i = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        strWhich = Request.QueryString["which"];
        strPageHeader = "";
        strSortby = "A";
        strHelpHint = "[Helpful Hint: All Hospitals are listed alphabetically.  Simply click on the first letter of your hospital, then click the box to the left of your selection.  Hit 'Select' at the top or bottom of the pop up window.  You may select multiple hospitals]";
        DataSet ds = null;
        if (Request.QueryString["sortby"] != null)
            strSortby = Request.QueryString["sortby"];

        string SQL = "";
        switch (strWhich)
        {
            case "1":
                strSortby = "";
                SQL = "select id,name as data from tbl_speciality where name like '" + strSortby + "%' order by name";
                strPageHeader = "Specialties";
                strHelpHint = "";
                pnlAlpha.Visible = false;
                break;
            case "2":
                SQL = "select Id, MedicalSchool as data from tbl_Medicalschool where isdelete=0 and MedicalSchool like '" + strSortby + "%' order by MedicalSchool";
                strPageHeader = "Medical Schools";
                strHelpHint = "[Helpful Hint: All Medical Schools are listed alphabetically.  Simply click on the first letter of your medical school, then click the box to the left of your selection.  Hit 'Select' at the top or bottom of the pop up window.]";
                break;
            case "3":
                strSortby = "";
                SQL = "select id, name as data from tbl_primaryspeciality where name like '" + strSortby + "%' order by name";
                strPageHeader = "Primary Specialties";
                strHelpHint = "";
                pnlAlpha.Visible = false;
                break;
            case "4":
                SQL = "select 0 as Id, HName as data from tbl_hospitals where isdelete=0 and HName like '" + strSortby + "%'order by hname";
                strPageHeader = "Hospitals";
                break;
            case "5":
                strSortby = "";
                SQL = "select id, name as data from tbl_secondaryspeciality where name like '" + strSortby + "%' order by name";
                strPageHeader = "Sub-Specialties";
                strHelpHint = "";
                pnlAlpha.Visible = false;
                break;
            case "6":
                //SQL = "select Id, MedicalSchool as data from tbl_Medicalschool where isdelete=0 and MedicalSchool like '" + strSortby + "%' order by MedicalSchool";
                SQL = "select Id, HName as data from tbl_hospitals  where isdelete=0 and HName like '" + strSortby + "%' order by hname";
                strPageHeader = "Residency Training";
                break;
            case "7":
                SQL = "select Id, HName as data from tbl_hospitals  where isdelete=0 and HName like '" + strSortby + "%' order by hname";
                strPageHeader = "Fellowships";
                break;
        }
        ds = _objDB.ExecuteQuery(SQL, "tbl");
        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
        {
            grdData.DataSource = ds;
            grdData.DataBind();
        }
        else
        {
            ltlError.Text = "No records found.";
            btnSelect.Visible = false;
            btnSelectTop.Visible = false;
        }
        lblPageHeader.Text = strPageHeader;
        lblHelpHint.Text = strHelpHint;
    }
    protected void grdData_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdData.PageIndex = e.NewPageIndex;
        grdData.DataBind();
    }


    protected void grdData_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        string id = "";
        string data = "";
        string strVal = "";
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            id = DataBinder.Eval(e.Row.DataItem, "Id").ToString();
            data = DataBinder.Eval(e.Row.DataItem, "Data").ToString();
            if (id.Equals("0"))
                strVal = data;
            else
                strVal = id + "~" + data;
            if (strWhich == "4")
                e.Row.Cells[0].Text = "<input type='checkbox' name='opSelect' id='Select' value='" + strVal + "'>";
            else
            {
                if (e.Row.RowIndex == 0)
                    e.Row.Cells[0].Text = "<input type='radio' name='opSelect' id='Select' value='" + strVal + "' checked/>";
                else
                    e.Row.Cells[0].Text = "<input type='radio' name='opSelect' id='Select' value='" + strVal + "'/>";
            }
        }
        Response.Flush();
    }

}
